package com.nisco.dms.repository;

import java.util.List;

import javax.persistence.QueryHint;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;

import com.nisco.dms.entity.Company;

/**
 * 
 * @author Robin
 *
 */
public interface CompanyDao extends JpaRepository<Company, String>{
	Page<Company> findByStrSnContaining(String strSn, Pageable pageable);
	
	Page<Company> findByStrNameContaining(String strName, Pageable pageable);
	
	Page<Company> findByStrDescContaining(String strDesc, Pageable pageable);
	
	Page<Company> findByStrSnContainingAndStrNameContaining(String strSn, String compName, Pageable pageable);
	
	@QueryHints(value={
			@QueryHint(name="org.hibernate.cacheable",value="true"),
			@QueryHint(name="org.hibernate.cacheRegion",value="com.nisco.dms.entity")
		}
	)
	@Query("from Company")
	List<Company> findAllWithCache();
	
	//@Query("select c from Company c where c.compId like ?1 and c.compName like ?2 and c.memo like ?3") 
	Page<Company> findByStrSnContainingAndStrNameContainingAndStrDescContaining(String strSn,String strName,String strDesc, Pageable pageable);
}
